CREATE TABLE [dbo].[TDREPO_CNTA]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TDREPO_CN__NU_AN__01142BA1] DEFAULT (datepart(year,getdate())),
[CO_REPO] [dbo].[TD_VC_003] NOT NULL,
[CO_TITU] [dbo].[TD_VC_003] NOT NULL,
[CO_SUBT] [dbo].[TD_VC_003] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TDREPO_CN__FE_US__03F0984C] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TDREPO_CN__FE_US__04E4BC85] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TDREPO_CNTA] ADD CONSTRAINT [CK__TDREPO_CN__CO_CN__02FC7413] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TDREPO_CNTA] ADD CONSTRAINT [CK__TDREPO_CN__NU_AN__02084FDA] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TDREPO_CNTA] ADD CONSTRAINT [XPKTDREPO_CNTA] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_ANNO], [CO_REPO], [CO_TITU], [CO_SUBT], [CO_CNTA_EMPR]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TDREPO_CNTA] ADD CONSTRAINT [FK1_TMPLAN_ANNO_A_TDREPO_CNTA] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
ALTER TABLE [dbo].[TDREPO_CNTA] ADD CONSTRAINT [FK1_TDREPO_SUBT_A_TDREPO_CNTA] FOREIGN KEY ([CO_EMPR], [NU_ANNO], [CO_REPO], [CO_TITU], [CO_SUBT]) REFERENCES [dbo].[TDREPO_SUBT] ([CO_EMPR], [NU_ANNO], [CO_REPO], [CO_TITU], [CO_SUBT])
GO
